//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package b;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class test {
    static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
    //static final String JDBC_DRIVER = "com.mysql.jc.jdbc.Driver";
    static final String DB_URL = "jdbc:mysql://localhost:3306/test?serverTimezone=GMT";
    static final String USER = "root";
    static final String PASS = "1224432083";
    static Connection conn = null;
    static Statement stmt = null;
    static ResultSet rs;

    public static void main(String[] args) {
        if (!(new test()).isLogin("lh", "1224432083").equals("")) {
            System.out.print("23333333\n");
        }

    }

    public test() {
        try {
            Class.forName(JDBC_DRIVER);
        } catch (Exception var2) {
            var2.printStackTrace();
        }

    }

    public String signup(String account, String password, String name) {
        try {
            String sql = "SELECT id,name,password FROM zh where account in ('" + account + "')";
            System.out.println("连接数据库...");
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?serverTimezone=GMT", "root", "1224432083");
            System.out.println(" 实例化Statement对象...");
            stmt = conn.createStatement();
            rs = stmt.executeQuery(sql);
            String var15;
            if (rs.next()) {
                System.out.println("该账号已被注册");
                rs.close();
                var15 = "该账号已被注册";
                return var15;
            }

            sql = "SELECT id,name,password FROM zh where name in ('" + name + "')";
            rs = stmt.executeQuery(sql);
            if (rs.next()) {
                System.out.println("该昵称已被注册");
                rs.close();
                var15 = "该昵称已被注册";
                return var15;
            }

            rs = stmt.executeQuery("select count(*) as result from zh");
            System.out.println("查询id");
            System.out.println(name);

            int count;
            for(count = 0; rs.next(); count = rs.getInt(1)) {
            }

            sql = "insert into zh(id,account,name,password) values(" + count + ",'" + account + "','" + name + "','" + password + "')";
            PreparedStatement p = null;
            p = conn.prepareStatement(sql);
            System.out.println("注册1");
            p.executeUpdate();
            System.out.println("注册成功");
            rs.close();
            p.close();
            conn.close();
            stmt.close();
            String var7 = "注册成功,您是第" + count + "位注册的大佬~~";
            return var7;
        } catch (SQLException var12) {
            var12.printStackTrace();
        } catch (Exception var13) {
            var13.printStackTrace();
        } finally {
            ;
        }

        System.out.println("Goodbye!");
        return "注册失败";
    }

    public String isLogin(String account, String password) {
        try {
            String sql = "SELECT id,account,name,password FROM zh where account in ('" + account + "')";
            System.out.println("连接数据库...");
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?serverTimezone=GMT", "root", "1224432083");
            System.out.println(" 实例化Statement对象...");
            System.out.println(account);
            stmt = conn.createStatement();
            rs = stmt.executeQuery(sql);

            String name;
            String passwordyz;
            do {
                if (!rs.next()) {
                    rs.close();
                    conn.close();
                    stmt.close();
                    String var15 = "";
                    return var15;
                }

                int id = rs.getInt("id");
                name = rs.getString("name");
                passwordyz = rs.getString("password");
                System.out.print("ID: " + id);
                System.out.print(", Account: " + account);
                System.out.print(", Name: " + name);
                System.out.print(", Password: " + passwordyz);
                System.out.print("\n");
            } while(!password.equals(passwordyz));

            return name;
        } catch (SQLException var12) {
            var12.printStackTrace();
        } catch (Exception var13) {
            var13.printStackTrace();
        } finally {
            ;
        }

        System.out.println("Goodbye!");
        return "";
    }
}
